package realQuestion.ali;

import java.util.Scanner;

public class Main2 {


    public static void main(String[] args) {
//        System.out.println("Not Over");
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int  x1 = scanner.nextInt();
        int  y1 = scanner.nextInt();
        int  x2 = scanner.nextInt();
        int  y2 = scanner.nextInt();
        String s1 = scanner.next();
        String s2 = scanner.next();
        int i=0;
        while (i<n){
            switch (s1.charAt(i)){
                case 'W':y1+=1; break;
                case 'A':x1-=1;break;
                case 'S':y1-=1;break;
                case 'D':x1+=1;break;

            }
            switch (s2.charAt(i)){
                case 'W':y2+=1;break;
                case 'A':x2-=1;break;
                case 'S':y2-=1;break;
                case 'D':x2+=1;
                    break;
            }
            i++;
            if (x1==x2&&y1==y2){
                System.out.println(i);
                break;
            }


        }
        if (i==n){
            System.out.println("Not  Over");
        }





    }

}
